class Solution {
public:
    int dp[210][210];
    
    int minPathSum(vector<vector<int>>& g) {
        memset(dp, 0x3f3f3f3f, sizeof dp);
        int n = g.size(), m = g[0].size();
        for (int i = 1; i <= n; i ++ ) 
            for (int j = 1; j <= m; j ++ ) {
                dp[i][j] = g[i - 1][j - 1];
                if (i == 1 && j == 1) continue;
                dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]);
            }
        return dp[n][m];
    }
};
